<include file="public/header" title="{$goods.goods_name}" />
<style>
    .dis{
        background: #ebebeb;
        color: #999;
        cursor: not-allowed;
        pointer-events:none;
    }
</style>
<div class="he_sustain">
    <div class="classreturn loginsignup detail">
        <div class="content">
            <div class="ds-in-bl return">
                <a href="javascript:history.back(-1)"><img src="__STATIC__/images/return.png" alt="返回"></a>
            </div>
            <div class="ds-in-bl search center">
                <span class="sxp">商品</span>
                <span>详情</span>
                <span>评论</span>
            </div>
            <div class="ds-in-bl menu">
                <a href="javascript:void(0);"><img src="__STATIC__/images/class1.png" alt="菜单"></a>
            </div>
        </div>
    </div>
</div>

<!--顶部隐藏菜单-s-->
<include file="public/top_nav" />
<!--顶部隐藏菜单-e-->

<!--商品s-->
<div class="xq_details">
    <div class="banner ban1 detailban">
        <div class="mslide" id="slideTpshop">
            <ul>
                <foreach name="goods_images_list" item="v">
                    <li><a href="javascript:void(0)"><img src="{$v[image_url]}" alt=""></a></li>
                </foreach>
            </ul>
        </div>
    </div>
    <div class="de_font p">
        <div class="thirty">
            <div class="fl">
                <span class="similar-product-text">{$goods.goods_name}</span>
            </div>
            <div class="keep fr">
                <a href="javascript:collect_goods({$goods.goods_id});" id="favorite_add">
                    <i class=" <if condition='$collect gt 0'>red</if>"></i>
                    <span>收藏</span>
                </a>
            </div>
            <div class="scunde p">
                <p class="red" id="price">预售价：￥{$pre_sell_info.price}</p>
                <p><span >{$pre_count_info.total_goods}人已参与</span><span class="kc red"></span></p>
                <p>定金：<span>￥{$pre_sell_info.deposit}</span><span>尾款：<span class="spec_store_count">￥{$pre_sell_info['price']-$pre_sell_info['deposit']}</span></span></p>
                <div class="pre_sell_desc" style="color:red;margin-top:10px;line-height:30px;">
                    <if condition="($pre_sell_info['end_time'] lt time()) OR ($pre_count_info['total_goods'] egt $pre_sell_info['restrict_amount'])">
                         <if condition="$pre_sell_info['is_finished'] eq 0">
                             <!-- 活动结束-s- -->
                             <div class="firde red">活动已结束，等待处理...</div>
                             <!-- 活动结束-s- -->
                         </if>
                         <if condition="$pre_sell_info['retainage_start'] gt 0">
                             <div class="firde red">支付尾款时间：{$pre_sell_info.retainage_start|date="Y/m/d H:i:s",###} - {$pre_sell_info.retainage_end|date="Y/m/d H:i:s",###}</div>
                             <div class="firde red">逾期未支付尾款，订单将关闭，且不退回订金</div>
                         </if>
                    <elseif condition="($pre_sell_info['end_time'] gt time()) AND ($pre_sell_info['start_time'] lt time())"/>
                         <!-- 预售活动进行时-s- -->
                         <div class="firde red">预售活动火热进行中！</div>
                         <!-- 预售活动进行时-e- -->
                     <else/>
                         <!-- 活动尚未开始button-s -->
                        <div class="firde red">活动尚未开始</div>
                         <!-- 活动尚未开始button-e -->
                     </if>
                </div>
            </div>
        </div>
    </div>
    <div class="floor list7 detailsfloo">
        <div class="myorder p choise_num">
            <div class="content30">
                <a href="javascript:void(0)">
                    <div class="order">
                        <div class="fl">
                            <span class="firde">已选</span>
                            <span class="sel"></span>
                        </div>
                        <div class="fr">
                            <i class="Mright"></i>
                        </div>
                    </div>
                </a>
            </div>
            </div>
        <div class="myorder p">
            <div class="content30">
                <a href="javascript:void(0)">
                    <div class="order">
                        <div class="fl">
                            <span class="firde">服务</span>
                            <span>由商城自营发货并提供售后服务</span>
                        </div>
                        <div class="fr">
                            <i class="Mright gt"></i>
                        </div>
                    </div>
                </a>
            </div>
        </div>
        <div class="myhearders myorder">
            <div class="scgz descgz">
                <ul>
                    <li>
                        <a href="javascript:void(0);">
                            <img src="__STATIC__/images/hdfk.png">
                            <p>货到付款</p>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0);">
                            <img src="__STATIC__/images/qttk.png">
                            <p>七天退款</p>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0);">
                            <img src="__STATIC__/images/ksd.png">
                            <p>极速达</p>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="myorder p seedeadei">
            <div class="content30">
                <a href="javascript:void(0)">
                    <div class="order">
                        <div class="fl">
                            <span class="firde red">查看商品详情</span>
                        </div>
                        <div class="fr">
                            <i class="Mright"></i>
                        </div>
                    </div>
                </a>
            </div>
        </div>
        <div class="myorder p tbv">
            <div class="content30">
                <a href="javascript:void(0)">
                    <div class="order">
                        <div class="fl">
                            <span class="firde">用户评价</span>
								<span>好评率<i>
                                <if condition="!empty($commentStatistics.c1) and !empty($commentStatistics.c0)">
                                    {:round($commentStatistics.c1/$commentStatistics.c0,3)*100}%
                                    <else/>0</if>
                            </i></span>
                        </div>
                        <div class="fr">
                            <span><i>{$commentStatistics.c0}</i>人评论</span>
                            <i class="Mright"></i>
                        </div>
                    </div>
                </a>
            </div>
        </div>
    </div>
    <div class="recommed p">
        <h2>为您推荐</h2>
        <div class="floor guesslike">
            <div class="likeshop">
                <ul>
                    <!--商品推荐-->
                    <tpshop sql="SELECT * FROM __PREFIX__goods WHERE ( is_recommend=1 and is_on_sale=1 ) ORDER BY goods_id DESC LIMIT 0,4 " key="k" item='v'>
                        <li>
                            <a href="{:U('Goods/goodsInfo',array('id'=>$v[goods_id]))}">
                                <div class="similer-product">
                                    <img src="{$v.goods_id|goods_thum_images=400,400}">
                                    <span class="similar-product-text">{$v[goods_name]}</span>
                                        <span class="similar-product-price">
                                            ¥<span class="big-price">{$v[shop_price]}</span>
                                        </span>
                                </div>
                            </a>
                        </li>
                    </tpshop>
                </ul>
            </div>
        </div>
    </div>
<!--添加购物车JS-->
    <script src="__PUBLIC__/js/mobile_common.js" type="text/javascript" charset="utf-8"></script>
</div>
<!--商品-e-->

<!--详情-s-->
    <div class="xq_details" style="display: none;">
    <div class="spxq-ggcs">
        <ul>
            <li class="red">商品详情</li>
            <li>规格参数</li>
        </ul>
    </div>
    <div class="sg">
        <div class="spxq p">
            {$goods.goods_content|htmlspecialchars_decode}
        </div>
    </div>
    <div class="sg" style="display: none;">
        <div class="spxq p">
            <table class="de_table" border="1" bordercolor="#cbcbcb" style="border-collapse:collapse;">
                <tr>
                    <th colspan="2">主体</th>
                </tr>
                <foreach name="goods_attr_list" item="v" key="k" >
                    <tr>
                        <td>{$goods_attribute[$v[attr_id]]}</td>
                        <td>{$v[attr_value]}</td>
                    </tr>
                </foreach>
            </table>
        </div>
    </div>
</div>
<!--详情-e-->

<!--评论列表-s-->
    <div class="xq_details" >
    <div class="spxq-ggcs comment_de p"  style="display:none;">
        <ul>
            <!--1 全部 2好评 3 中评 4差评-->
            <li class="red">全部评价 <br /><span ctype="1">{$commentStatistics.c0}</span></li>
            <li>好评 <br /><span ctype="2">{$commentStatistics.c1}</span></li>
            <li>中评 <br /><span ctype="3">{$commentStatistics.c2}</span></li>
            <li>差评 <br /><span ctype="4">{$commentStatistics.c3}</span></li>
            <li>有图 <br /><span ctype="5"></span></li>
        </ul>
    </div>
    <!--评论列表-->
    <div class="tab-con-wrapper my_comment_list" > </div>
</div>
<!--评论列表-e-->

<!--底部按钮-s-->
<div class="podee">
    <div class="cart-concert-btm p">
        <div class="fl">
            <ul>
                <li>
                    <a href="tel:{$tpshop_config['shop_info_phone']}">
                        <i></i>
                        <p>客服</p>
                    </a>
                </li>
                <li>
                    <a href="{:U('Mobile/Cart/index')}" >
                        <span id="tp_cart_info"></span>
                        <i class="gwc"></i>
                        <p>购物车</p>
                    </a>
                </li>
            </ul>
        </div>
        <div class="fr">
            <ul>
                <li class="r" style="width: 100%">
                    <if condition="($pre_sell_info['end_time'] lt time()) OR ($pre_count_info['total_goods'] egt $pre_sell_info['restrict_amount'])">
                        <!-- 活动结束button-s -->
                        <a class="dis" style="display:block;" href="javascript:void(0);">活动已结束</a>
                        <!-- 活动结束button-e -->
                        <elseif condition="($pre_sell_info['end_time'] gt time()) AND ($pre_sell_info['start_time'] lt time())"/>
                        <if condition="$pre_sell_info['deposit'] gt 0">
                            <!-- 活动支付button-s -->
                            <a class="choise_num" style="display:block;" href="javascript:void(0);">立刻支付定金</a>
                            <!-- 活动支付button-e -->
                            <else />
                            <!-- 活动支付button-s -->
                            <a class="choise_num" style="display:block;" href="javascript:void(0);">立刻预定商品</a>
                            <!-- 活动支付button-e -->
                        </if>
                        <else/>
                        <!-- 活动尚未开始button-s -->
                        <a class="dis" style="display:block;" href="javascript:void(0);">立即购买</a>
                        <!-- 活动尚未开始button-e -->
                    </if>
                </li>
            </ul>
        </div>
    </div>
</div>
<!--底部按钮-e-->

<!--点赞弹窗-s-->
<div class="alert">
    <img src="__STATIC__/images/hh.png"/>
    <p>您已经赞过了！</p>
</div>
<!--点赞弹窗-e-->
<!--选择属性的弹窗-s-->
<form id="buy_goods_form" name="buy_goods_form" method="post" action="{:U('Cart/pre_sell_cart')}">
    <input type="hidden" value="{$pre_sell_info['act_id']}" name="act_id">

    <div class="choose_shop_aready p">
        <!--商品信息-s-->
        <div class="shop-top-under p">
            <div class="maleri30">
                <div class="shopprice">
                    <div class="img_or fl"><img id="zoomimg" src="{$goods.original_img}"></div>
                    <div class="fon_or fl">
                        <h2 class="similar-product-text">{$goods.goods_name}</h2>
                        <input type="hidden" id="goods_name" name="goods_id" value="{$goods.goods_id}">

                        <div class="price_or" id="goods_price"><span>￥</span><span>{$goods.shop_price}</span></div>
                        <div class="dqkc_or"><span>剩余库存：</span><span id="store_count">{$pre_sell_info['restrict_amount']-$pre_count_info['total_goods']}</span></div>
                    </div>
                    <div class="price_or fr">
                        <i class="xxgro"></i>
                    </div>
                </div>
            </div>
        </div>
        <!--商品信息-e-->
        <div class="shop-top-under p">
            <div class="maleri30">
                <div class="shulges p">
                    <p>数量</p>
                    <!--选择数量-->
                    <div class="plus">
                        <span class="mp_minous" onclick="altergoodsnum(-1)">-</span>
                                <span class="mp_mp">
                        <input type="tel" class="num buyNum" id="number" name="goods_num" value="1" min="1" max="{$pre_sell_info['restrict_amount']-$pre_count_info['total_goods']}"
                               onblur="altergoodsnum(0)">
                                </span>
                        <span class="mp_plus" onclick="altergoodsnum(1)">+</span>
                    </div>
                </div>

            </div>
        </div>
        <div class="plusshopcar-buy p">
            <a class="pb_buy dis_btn" href="javascript:void(0);" onclick="$('#buy_goods_form').submit();">立即购买 </a>
        </div>
    </div>
</form>
<!--选择属性的弹窗-e-->

<div class="mask-filter-div" style="display: none;"></div>
<!--添加购物车JS-->
<script src="__PUBLIC__/js/mobile_common.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    /**
     * 点击收藏商品
     */
    function collect_goods(goods_id){
        $.ajax({
            type : "GET",
            dataType: "json",
            url:"/index.php?m=Home&c=goods&a=collect_goods&goods_id="+goods_id,//+tab,
            success: function(data){
                showErrorMsg(data.msg);
                if(data.status == '1'){
                    //收藏点亮
                    $('.de_font .keep').find('i').addClass('red');
                }
            }
        });
    }

    /**
     * 加减数量
     * n 点击一次要改变多少
     * maxnum 允许的最大数量(库存)
     * number ，input的id
     */
    function altergoodsnum(n){
        var num = parseInt($('#number').val());
        var maxnum = parseInt($('#number').attr('max'));
        num += n;
        num <= 0 ? num = 1 :  num;
        if(num >= maxnum){
            $(this).addClass('no-mins');
            num = maxnum;
        }
        $('#store_count').text(maxnum-num); //更新库存数量
        $('#number').val(num)
    }

//页面加载后执行
$(document).ready(function(){
        /**
         * ajax请求购物车列表
         */
        var cart_cn = getCookie('cn');
        if(cart_cn == ''){
            $.ajax({
                type : "GET",
                url:"/index.php?m=Home&c=Cart&a=header_cart_list",//+tab,
                success: function(data){
                    cart_cn = getCookie('cn');
                }
            });
        }
        $('#tp_cart_info').html(cart_cn);

        /**
         * 查看商品详情
         */
        $('.seedeadei').click(function(){
            $('.xq_details').eq(0).hide();
            $('.xq_details').eq(1).show();
            $('body').animate({ scrollTop: 0 }, 0);
            $('.detail').find('.center').find('span').eq(1).addClass('sxp');
            $('.detail').find('.center').find('span').eq(0).removeClass('sxp');
        })

        /**
         * 评论
         */
        $('.tbv').click(function(){
            $('.xq_details').eq(0).hide();
            $('.xq_details').eq(2).show();
            $('body').animate({ scrollTop: 0 }, 0);
            $('.detail').find('.center').find('span').eq(2).addClass('sxp');
            $('.detail').find('.center').find('span').eq(0).removeClass('sxp');
            $('.gizle').show();
        })

        /**
         * 加载评论
         */
        commentType = 1; // 评论类型
        ajaxComment(1,1);// ajax 加载评价列表

        /**
         * 加载更多评论
         */
        function ajaxComment(commentType,page){
            $.ajax({
                type : "GET",
                url:"/index.php?m=Mobile&c=goods&a=ajaxComment&goods_id={$goods['goods_id']}&commentType="+commentType+"&p="+page,//+tab,
                success: function(data){
                    $(".my_comment_list").empty().append(data);
                }
            });
        }
    /**
     * 已选
     */
    $('.choise_num').click(function () {
        cover();
        $('.choose_shop_aready').show();
        $('.podee').hide();
    })
    //关闭属性选择
    $('.xxgro').click(function () {
        undercover();
        $('.choose_shop_aready').hide();
        $('.podee').show();
        sel();
    })
        //点赞
        function hde(){
            setTimeout(function(){
                $('.alert').hide();
            },1200)
        }

        /**
         * 顶部导航切换
         */
        $('.detail .search span').click(function(){
            $(this).addClass('sxp').siblings().removeClass('sxp');
            var a = $('.detail .search span').index(this);
            $('.xq_details').eq(a).show().siblings('.xq_details').hide();
            $('.xq_details').eq(2).show();
            if($('.detail .search span').eq(2).hasClass('sxp')){
                $('.comment_de').show();
            }else{
                $('.comment_de').hide();
            }
            if($('.detail .search span').eq(1).hasClass('sxp')){
                $('.tab-con-wrapper').hide();
                $('.comment_con').hide();
            }else{
                $('.tab-con-wrapper').show();
                $('.comment_con').show();
            }
        });

        /**
         * 内部导航切换
         */
        $('.spxq-ggcs ul li').click(function(){
            $(this).addClass('red').siblings().removeClass('red');
            var sg = $('.spxq-ggcs ul li').index(this);
            $('.sg').eq(sg).show().siblings('.sg').hide();
            var $commentType= $(this).children('span').attr('ctype');
            //切换到评论按钮才加载评论列表
            if($('.detail .search span').eq(2).hasClass('sxp')){
                ajaxComment($commentType,1);// ajax 加载评价列表
            }
        });

        /**
         * 内部导航随鼠标滑动显示隐藏
         */
        var h1 = $('.detail').height();
        var h2 = $('.detail').height() + $('.spxq-ggcs').height();
        var ss = $(document).scrollTop();//上一次滚轮的高度
        $(window).scroll(function(){
            var s = $(document).scrollTop();////本次滚轮的高度

            if(s< h1){
                $('.spxq-ggcs').removeClass('po-fi');
            }if(s > h1){
                $('.spxq-ggcs').addClass('po-fi');
            }if(s > h2){
                $('.spxq-ggcs').addClass('gizle');
                if(s > ss){
                    $('.spxq-ggcs').removeClass('sabit');
                }else{
                    $('.spxq-ggcs').addClass('sabit');
                }
                ss = s;
            }
        });
    });
</script>
</body>
</html>
